import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const constRouter = [
  {
    path: '/',
    component: () => import('@/views/index.vue'),
    redirect: '/home1',
    children: [
      {
        path: '/home1',
        component: () => import('@/views/Home1.vue')
        /*
            beforeEnter:(to,from,next)=>{}
        */
      }
    ]
  },
  {
    path: '/home2',
    name: 'home2',
    component: () => import('@/views/Home2.vue')
  },
  {
    path: '/home3',
    name: 'home3',
    component: () => import('@/views/Home3.vue')
  },
  {
    path: '/home4',
    name: 'home4',
    component: () => import('@/views/Home4.vue')
  },
  {
    path: '/home5',
    name: 'home5',
    component: () => import('@/views/Home5.vue'),
    children: [
      {
        path: 'pp',
        component: () => import('@/views/pp.vue')
      }
    ]
  },
  {
    path: '/home6',
    name: 'home6',
    component: () => import('@/views/Home6.vue')
  },
  {
    path: '/home7',
    name: 'home7',
    component: () => import('@/views/Home7.vue')
  },
  {
    path: '/home8',
    name: 'home8',
    component: () => import('@/views/Home8.vue')
  },
  {
    path: '/home9',
    name: 'home9',
    component: () => import('@/views/Home9.vue')
  }
]

const router = new VueRouter({
  routes: constRouter
})
router.beforeEach((to, from, next) => {
  if (to.path === '/home9') {
    next('/home3')
  }
  next()
})
/*
router.beforEach(to,from,next)=>{}

*/
export default router
